}
}
consumer.endElement("", "menue", "menue");
}
SessionContext context = this.getSunRiseSessionContext(true);
synchronized (context) {
String state = this.request.getParameter(SunRise.REQ_PARAMETER_STATE);
if (state == null) {
state = (isAdmin == true ? "main" : "seluser");
}
if (state.equals("addrole") == true) {
String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
if (role != null && role.trim().length() > 0) {
SourceParameters pars = new SourceParameters();
// first include all request parameters
Enumeration requestParameters = this.request.getParameterNames();
String current;
while (requestParameters.hasMoreElements() == true) {
current = (String)requestParameters.nextElement();
pars.setParameter(current, this.request.getParameter(current));
}
this.addRole(role, pars);
} else {
role = null;
}
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
}
if (state.equals("delrole") == true) {
try {
String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
if (role != null) {
// first delete user
DocumentFragment userDF = this.getUsers(role, null);
NodeList users = null;
if (userDF != null) users = XMLUtil.selectNodeList(userDF, "users/user");
if (users != null) {
for(int i = 0; i < users.getLength(); i++) {
this.deleteUser(role, XMLUtil.getValueOf(users.item(i), "ID"), null);
}
}
this.deleteRole(role, null);
}
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
}
if (state.equals("chguser") == true) {
String role;
String id;
String user;
if (isAdmin == false) {
SourceParameters pars = this.createParameters(null);
id = pars.getParameter("ID", null);
role = pars.getParameter("role", null);
user = "old";
} else {
role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
id = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
user = this.request.getParameter(SunRise.REQ_PARAMETER_USER);
}
boolean addingNewUserFailed = false;
if (role != null && id != null && user != null) {
if (user.equals("new") == true) {
SourceParameters pars = new SourceParameters();
// first include all request parameters
Enumeration requestParameters = this.request.getParameterNames();
String current;
while (requestParameters.hasMoreElements() == true) {
current = (String)requestParameters.nextElement();
pars.setParameter(current, this.request.getParameter(current));
}
addingNewUserFailed = !this.addUser(role, id, pars);
if (addingNewUserFailed == false) {
consumer.startElement("", "addeduser", "addeduser", attr);
consumer.characters(id.toCharArray(), 0, id.length());
consumer.endElement("", "addeduser", "addeduser");
}
} else {
String delete = this.request.getParameter("sunrisedeluser");
if (delete != null && delete.equals("true") == true) {
this.deleteUser(role, id, null);
} else {
SourceParameters pars = new SourceParameters();
// first include all request parameters
Enumeration requestParameters = this.request.getParameterNames();
String current;
while (requestParameters.hasMoreElements() == true) {
current = (String)requestParameters.nextElement();
pars.setParameter(current, this.request.getParameter(current));
}
this.changeUser(role, id, pars);
}
}
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, null);
}
if (addingNewUserFailed == false) {
state = (isAdmin == true ? "adduser" : "seluser");
} else {
state = "erruser";
}
}
if (state.equals("seluser") == true) {
String role;
String id;
if (isAdmin == false) {
SourceParameters pars = this.createParameters(null);
id = pars.getParameter("ID", null);
role = pars.getParameter("role", null);
} else {
role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
id = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
}
if (role != null && id != null) {
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);
// include users
DocumentFragment userDF = this.getUsers(role, id);
Element users = null;
try {
if (userDF != null) users = (Element)XMLUtil.getSingleNode(userDF, "users/user");
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
consumer.startElement("", "uservalues", "uservalues", attr);
if (users != null && users.hasChildNodes() == true) {
NodeList childs = users.getChildNodes();
for(int i = 0; i < childs.getLength(); i++) {
if (childs.item(i).getNodeType() == Node.ELEMENT_NODE)
IncludeXMLConsumer.includeNode(childs.item(i), consumer, consumer);
}
}
consumer.endElement("", "uservalues", "uservalues");
}
consumer.startElement("", "user", "user", attr);
consumer.characters("old".toCharArray(), 0, 3);
consumer.endElement("", "user", "user");
if (isAdmin == false) {
consumer.startElement("", "role", "role", attr);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}
}
if (state.equals("erruser") == true) {
String role;
String id;
if (isAdmin == false) {
SourceParameters pars = this.createParameters(null);
id = pars.getParameter("ID", null);
role = pars.getParameter("role", null);
} else {
role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
id = this.request.getParameter(SunRise.REQ_PARAMETER_ID);
}
if (role != null && id != null) {
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);
// include users
DocumentFragment userDF = this.getUsers(role, id);
Element users = null;
try {
if (userDF != null) users = (Element)XMLUtil.getSingleNode(userDF, "users/user");
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
consumer.startElement("", "uservalues", "uservalues", attr);
if (users != null && users.hasChildNodes() == true) {
NodeList childs = users.getChildNodes();
for(int i = 0; i < childs.getLength(); i++) {
if (childs.item(i).getNodeType() == Node.ELEMENT_NODE)
IncludeXMLConsumer.includeNode(childs.item(i), consumer, consumer);
}
}
consumer.endElement("", "uservalues", "uservalues");
}
consumer.startElement("", "user", "user", attr);
consumer.characters("error".toCharArray(), 0, 5);
consumer.endElement("", "user", "user");
if (isAdmin == false) {
consumer.startElement("", "role", "role", attr);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}
}
if (state.equals("adduser") == true) {
consumer.startElement("", "user", "user", attr);
consumer.characters("new".toCharArray(), 0, 3);
consumer.endElement("", "user", "user");
}
if (state.equals("selrole") == true) {
String role = this.request.getParameter(SunRise.REQ_PARAMETER_ROLE);
context.setAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE, role);
// include users
DocumentFragment userDF = this.getUsers(role, null);
Node users = null;
try {
if (userDF != null) users = XMLUtil.getSingleNode(userDF, "users");
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
IncludeXMLConsumer.includeNode(users, consumer, consumer);
}
if (isAdmin == true) {
// include roles
DocumentFragment rolesDF = this.getRoles();
Node roles = null;
try {
if (rolesDF != null) roles = XMLUtil.getSingleNode(rolesDF, "roles");
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
IncludeXMLConsumer.includeNode(roles, consumer, consumer);
// include selected role
String role = (String)context.getAttribute(SunRise.SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE);
if (role != null) {
consumer.startElement("", "role", "role", attr);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}