Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java +3 −1 Original line number Diff line number Diff line Loading @@ -185,7 +185,9 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO group.getUserAdmins(), group.getGroupAdmins()); LdapDAO.checkLdapResult(result.getResultCode()); // AD: Search results sometimes come incomplete if // connection is not reset - not sure why. getConnection().reconnect(); try { return getGroup(group.getID()); Loading projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/web/ACSearchRunner.java +41 −19 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ import ca.nrc.cadc.uws.server.JobRunner; import ca.nrc.cadc.uws.server.JobUpdater; import ca.nrc.cadc.uws.server.SyncOutput; import ca.nrc.cadc.uws.util.JobLogInfo; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; public class ACSearchRunner implements JobRunner { Loading Loading @@ -225,8 +228,15 @@ public class ACSearchRunner implements JobRunner PluginFactory factory = new PluginFactory(); GroupPersistence dao = factory.getGroupPersistence(); Collection<Group> groups = dao.getGroups(rv.getPrincipal(), rv.getRole(), rv.getGroupID()); Collection<Group> groups; try { groups = dao.getGroups(rv.getPrincipal(), rv.getRole(), rv.getGroupID()); } catch(GroupNotFoundException ignore) { groups = new ArrayList<Group>(); } syncOut.setResponseCode(HttpServletResponse.SC_OK); GroupsWriter.write(groups, syncOut.getOutputStream()); Loading @@ -241,7 +251,7 @@ public class ACSearchRunner implements JobRunner log.error("FAIL", t); syncOut.setResponseCode(503); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -266,12 +276,12 @@ public class ACSearchRunner implements JobRunner } catch (UserNotFoundException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(404); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -294,14 +304,15 @@ public class ACSearchRunner implements JobRunner // log.debug("failed to set final error status after " + t, oops); // } } /* catch (GroupNotFoundException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(404); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -324,14 +335,15 @@ public class ACSearchRunner implements JobRunner // log.debug("failed to set final error status after " + t, oops); // } } */ catch (AccessControlException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(403); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading Loading @@ -360,16 +372,7 @@ public class ACSearchRunner implements JobRunner logInfo.setMessage(t.getMessage()); log.error("FAIL", t); syncOut.setResponseCode(500); syncOut.setHeader("Content-Type", "text/plan"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); } catch (IOException e) { log.warn("Could not write response to output stream", e); } writeError(syncOut, 500, t); // ErrorSummary errorSummary = // new ErrorSummary(t.getMessage(), ErrorType.FATAL); Loading @@ -386,4 +389,23 @@ public class ACSearchRunner implements JobRunner } } private void writeError(SyncOutput syncOutput, int code, Throwable t) { try { syncOutput.setResponseCode(code); syncOut.setHeader("Content-Type", "text/plain"); OutputStream ostream = syncOut.getOutputStream(); if (ostream != null) { OutputStreamWriter w = new OutputStreamWriter(ostream); w.write(t.toString()); w.flush(); } } catch (IOException e) { log.warn("Could not write response to output stream", e); } } } Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupDAO.java +3 −1 Original line number Diff line number Diff line Loading @@ -185,7 +185,9 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO group.getUserAdmins(), group.getGroupAdmins()); LdapDAO.checkLdapResult(result.getResultCode()); // AD: Search results sometimes come incomplete if // connection is not reset - not sure why. getConnection().reconnect(); try { return getGroup(group.getID()); Loading
projects/cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/web/ACSearchRunner.java +41 −19 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ import ca.nrc.cadc.uws.server.JobRunner; import ca.nrc.cadc.uws.server.JobUpdater; import ca.nrc.cadc.uws.server.SyncOutput; import ca.nrc.cadc.uws.util.JobLogInfo; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; public class ACSearchRunner implements JobRunner { Loading Loading @@ -225,8 +228,15 @@ public class ACSearchRunner implements JobRunner PluginFactory factory = new PluginFactory(); GroupPersistence dao = factory.getGroupPersistence(); Collection<Group> groups = dao.getGroups(rv.getPrincipal(), rv.getRole(), rv.getGroupID()); Collection<Group> groups; try { groups = dao.getGroups(rv.getPrincipal(), rv.getRole(), rv.getGroupID()); } catch(GroupNotFoundException ignore) { groups = new ArrayList<Group>(); } syncOut.setResponseCode(HttpServletResponse.SC_OK); GroupsWriter.write(groups, syncOut.getOutputStream()); Loading @@ -241,7 +251,7 @@ public class ACSearchRunner implements JobRunner log.error("FAIL", t); syncOut.setResponseCode(503); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -266,12 +276,12 @@ public class ACSearchRunner implements JobRunner } catch (UserNotFoundException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(404); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -294,14 +304,15 @@ public class ACSearchRunner implements JobRunner // log.debug("failed to set final error status after " + t, oops); // } } /* catch (GroupNotFoundException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(404); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading @@ -324,14 +335,15 @@ public class ACSearchRunner implements JobRunner // log.debug("failed to set final error status after " + t, oops); // } } */ catch (AccessControlException t) { logInfo.setSuccess(false); logInfo.setSuccess(true); logInfo.setMessage(t.getMessage()); log.debug("FAIL", t); syncOut.setResponseCode(403); syncOut.setHeader("Content-Type", "text/plan"); syncOut.setHeader("Content-Type", "text/plain"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); Loading Loading @@ -360,16 +372,7 @@ public class ACSearchRunner implements JobRunner logInfo.setMessage(t.getMessage()); log.error("FAIL", t); syncOut.setResponseCode(500); syncOut.setHeader("Content-Type", "text/plan"); try { syncOut.getOutputStream().write(t.getMessage().getBytes()); } catch (IOException e) { log.warn("Could not write response to output stream", e); } writeError(syncOut, 500, t); // ErrorSummary errorSummary = // new ErrorSummary(t.getMessage(), ErrorType.FATAL); Loading @@ -386,4 +389,23 @@ public class ACSearchRunner implements JobRunner } } private void writeError(SyncOutput syncOutput, int code, Throwable t) { try { syncOutput.setResponseCode(code); syncOut.setHeader("Content-Type", "text/plain"); OutputStream ostream = syncOut.getOutputStream(); if (ostream != null) { OutputStreamWriter w = new OutputStreamWriter(ostream); w.write(t.toString()); w.flush(); } } catch (IOException e) { log.warn("Could not write response to output stream", e); } } }