try {
shortName = body.getParameterValues("shortName")[0];
} catch (Exception ex) {
}
if (shortName == null) {
throw new HandlerException("Must specify a shortName parameter");
}
String password = body.getParameterValues("password")[0];
String create = null;
try {
create = body.getParameterValues("create")[0];
} catch (Exception ex) {
}
ResIterator users = model.listSubjectsWithProperty(
AUTHORIZATION.shortName, shortName);
if (users.hasNext()) {
user = users.nextResource();
}
/*
* RDF.type, AUTHORIZATION.User); while (users.hasNext()) { Resource
* current = users.nextResource(); if
* (shortName.equals(current.getProperty(
* AUTHORIZATION.shortName).getString())) { user = current; } }
*/
users.close();
if ((user == null) && ("true".equals(create))) {
user = model.createResource();
user.addProperty(RDF.type, AUTHORIZATION.User);
user.addProperty(AUTHORIZATION.shortName, shortName);
}
boolean delete = false;
try {
delete = "delete".equals(body.getParameterValues("delete")[0]);
} catch (Exception ex) {
}
if (delete) {
user.removeProperties();
new org.wymiwyg.rwcf.util.EnhancedResponse(response)
.sendRedirect("/admin/user_manager");
return;
}
user.removeAll(AUTHORIZATION.password);
user.removeAll(AUTHORIZATION.pass_sha1sum);
user.addProperty(AUTHORIZATION.pass_sha1sum, Util.sha1(password));
String[] permissionStrings = body.getParameterValues("permission");
user.removeAll(AUTHORIZATION.permission);
if (permissionStrings != null) {
for (int i = 0; i < permissionStrings.length; i++) {
user.addProperty(AUTHORIZATION.permission, model
.createResource(permissionStrings[i]));
}
}
} else {
String shortName = null;
try {
shortName = request.getRequestURI().getParameterValues(
"shortName")[0];
} catch (Exception ex) {
}
if (shortName == null) {
throw new HandlerException("Must specify a shortName parameter");
}
/*
* String password = request.getRequestURI()
* .getParameterValues("password")[0];
*/
String create = null;
try {
create = request.getRequestURI().getParameterValues("create")[0];
} catch (Exception ex) {
}
ResIterator users = model.listSubjectsWithProperty(
AUTHORIZATION.shortName, shortName);
user = users.nextResource();
/*
* RDF.type, AUTHORIZATION.User); while (users.hasNext()) { Resource
* current = users.nextResource(); if
* (shortName.equals(current.getProperty(
* AUTHORIZATION.shortName).getString())) { user = current; } }
*/
users.close();
}
response.setHeader(HeaderName.CONTENT_TYPE, "application/xhtml+xml");
PipedWriter pipedOut = new PipedWriter();
PipedReader pipedIn;
try {
pipedIn = new PipedReader(pipedOut);
response.setBody(pipedIn);
PrintWriter out = new PrintWriter(pipedOut);
printHeader(out);
printTemplate(out, user);
printFooter(out);
out.close();
} catch (IOException ex) {
throw new HandlerException(ex);
}
//response.sendRedirect(go);
}