use of com.iplanet.services.naming.share.NamingResponse in project OpenAM by OpenRock.
the class NamingService method processRequest.
private Response processRequest(Request req) {
String content = req.getContent();
NamingRequest nreq = NamingRequest.parseXML(content);
NamingResponse nres = new NamingResponse(nreq.getRequestID());
// get the version from nreq and check old
float reqVersion = Float.valueOf(nreq.getRequestVersion()).floatValue();
boolean limitNametable = (reqVersion > 1.0);
// get the sesisonId from nreq
String sessionId = nreq.getSessionId();
try {
if (sessionId == null) {
nres.setNamingTable(NamingService.getNamingTable(limitNametable));
} else {
Hashtable tempHash = new Hashtable();
tempHash = transferTable(NamingService.getNamingTable(limitNametable));
Hashtable replacedTable = null;
URL url = usePreferredNamingURL(nreq, reqVersion);
if (url != null) {
String uri = (reqVersion < 3.0) ? SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR) : WebtopNaming.getURI(url);
if (uri.equals(Constants.EMPTY)) {
uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
if (namingDebug.messageEnabled()) {
namingDebug.message("uri is blank; adding " + uri);
}
}
replacedTable = replaceTable(tempHash, url.getProtocol(), url.getHost(), Integer.toString(url.getPort()), uri);
} else {
replacedTable = replaceTable(tempHash, sessionId);
}
if (replacedTable == null) {
nres.setException("SessionID ---" + sessionId + "---is Invalid");
} else {
nres.setNamingTable(replacedTable);
}
nres.setAttribute(Constants.NAMING_AM_LB_COOKIE, sessionCookies.getLBCookie(sessionId));
}
} catch (Exception e) {
String errorMsg = "Failed to process naming request";
namingDebug.error(errorMsg, e);
if (e.getMessage() != null) {
errorMsg = e.getMessage();
}
nres.setException(errorMsg);
}
// %uri with the actual value
if (reqVersion < 3.0) {
String uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
if (!uri.startsWith("/")) {
uri = "/" + uri;
}
nres.replaceURI(uri);
}
return new Response(nres.toXMLString());
}
use of com.iplanet.services.naming.share.NamingResponse in project OpenAM by OpenRock.
the class WebtopNaming method getNamingTable.
private static Hashtable getNamingTable(URL nameurl) throws Exception {
Hashtable nametbl = null;
NamingRequest nrequest = new NamingRequest(NamingRequest.reqVersion);
Request request = new Request(nrequest.toXMLString());
RequestSet set = new RequestSet(NAMING_SERVICE);
set.addRequest(request);
Vector responses = null;
try {
responses = PLLClient.send(nameurl, set);
if (responses.size() != 1) {
throw new Exception(NamingBundle.getString("unexpectedResponse"));
}
Response res = (Response) responses.elementAt(0);
NamingResponse nres = NamingResponse.parseXML(res.getContent());
if (nres.getException() != null) {
throw new Exception(nres.getException());
}
nametbl = nres.getNamingTable();
} catch (SendRequestException sre) {
debug.error("Naming service connection failed for " + nameurl, sre);
} catch (Exception e) {
debug.error("getNamingTable: ", e);
}
return nametbl;
}
Aggregations