Index: lams_central/src/java/org/lamsfoundation/lams/web/shibboleth/FedRegistryUpdateServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/shibboleth/Attic/FedRegistryUpdateServlet.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_central/src/java/org/lamsfoundation/lams/web/shibboleth/FedRegistryUpdateServlet.java 27 Aug 2007 05:46:08 -0000 1.1.2.1 +++ lams_central/src/java/org/lamsfoundation/lams/web/shibboleth/FedRegistryUpdateServlet.java 9 Oct 2007 02:03:01 -0000 1.1.2.2 @@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.federation.FederationException; import org.lamsfoundation.lams.federation.service.IFederationService; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -51,8 +50,9 @@ response.getWriter().println(resultsMap.get(service.RESULTS_NEW)+" new servers."); response.getWriter().println(resultsMap.get(service.RESULTS_UPDATED)+" servers updated."); response.getWriter().println(resultsMap.get(service.RESULTS_DELETED)+" servers deleted."); - } catch (FederationException e) { + } catch (Exception e) { log.error("Error updating federation server registry: ", e); + response.getWriter().println("Error updating federation server registry: " + e); } } } Index: lams_common/src/java/org/lamsfoundation/lams/federation/service/FederationService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/federation/service/Attic/FederationService.java,v diff -u -r1.1.2.22 -r1.1.2.23 --- lams_common/src/java/org/lamsfoundation/lams/federation/service/FederationService.java 30 Aug 2007 07:51:15 -0000 1.1.2.22 +++ lams_common/src/java/org/lamsfoundation/lams/federation/service/FederationService.java 9 Oct 2007 02:03:00 -0000 1.1.2.23 @@ -97,11 +97,13 @@ return (list == null || list.isEmpty()) ? null : (FederationServer)list.get(0); } - private Document getXmlDocumentFromUrl(URL url) throws FederationException { + private Document getXmlDocumentFromUrl(URL url) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException { return getXmlDocumentFromUrl(url, ""); } - private Document getXmlDocumentFromUrl(URL url, String key) throws FederationException { + private Document getXmlDocumentFromUrl(URL url, String key) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException { HttpURLConnection conn = null; try { conn = (HttpURLConnection)url.openConnection(); @@ -116,21 +118,11 @@ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setValidating(false); return docBuilderFactory.newDocumentBuilder().parse(conn.getInputStream()); - } catch (MalformedURLException e) { - log.error("Invalid URL: "+url, e); - } catch (IOException e) { - // java.net.ConnectException: Connection refused: connect (server not running) - log.error("Couldn't connect to URL: "+url, e); - } catch (SAXException e) { - log.error("Encountered SAXException error...", e); - } catch (ParserConfigurationException e) { - log.error("Encountered ParserConfigurationException error...", e); } finally { if (conn != null) { conn.disconnect(); } } - return null; } private ExtOrgDTO getExtOrgDTOFromNode(Node node) { @@ -208,21 +200,18 @@ return message; } - public List getFedServerGroups(Integer fedId) throws FederationException { + public List getFedServerGroups(Integer fedId) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException { FederationServer fedServer = getFedServerByFedId(fedId); String fedKey = HashUtil.sha1(fedServer.getPrivateKey()); String urlText = fedServer.getUrl() + "/federation/groups?h=" + fedKey; ArrayList list = new ArrayList(); - try { - Document document = getXmlDocumentFromUrl(new URL(urlText)); - NodeList nodeList = document.getElementsByTagName("row"); - for (int i=0; i getFedServerLessons(Integer fedId, Integer orgId) throws FederationException { + public List getFedServerLessons(Integer fedId, Integer orgId) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException { FederationServer fedServer = getFedServerByFedId(fedId); String fedKey = HashUtil.sha1(fedServer.getPrivateKey()); String urlText = fedServer.getUrl() + "/federation/lessons?h=" + fedKey + "&oid=" + orgId + "&fid=" + getFedServerByURLHost(getHost(Configuration.get(ConfigurationKeys.SERVER_URL))).getFedId(); ArrayList list = new ArrayList(); - try { - Document document = getXmlDocumentFromUrl(new URL(urlText)); - NodeList nodeList = document.getElementsByTagName("row"); - for (int i=0; i resultsMap = new HashMap(); resultsMap.put(RESULTS_NEW, 0); resultsMap.put(RESULTS_UPDATED, 0); resultsMap.put(RESULTS_DELETED, 0); - try { - // add federation key - Document document = getXmlDocumentFromUrl(new URL(url), HashUtil.sha1(getFederationKey())); - NodeList nodeList = document.getElementsByTagName("row"); - ArrayList newFedList = new ArrayList(); + // add federation key + Document document = getXmlDocumentFromUrl(new URL(url), HashUtil.sha1(getFederationKey())); + NodeList nodeList = document.getElementsByTagName("row"); + ArrayList newFedList = new ArrayList(); - // update and insert new servers received from registry - for (int i=0; i getFedServerGroups(Integer fedId) throws FederationException; + public List getFedServerGroups(Integer fedId) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException; /** * Wrapper method to return WDDX packet string of getFedServerLessons. @@ -69,7 +74,8 @@ * @param orgId * @return lesson ids and names from federation server with given fed_id, available to org with given orgId. */ - public List getFedServerLessons(Integer fedId, Integer orgId) throws FederationException; + public List getFedServerLessons(Integer fedId, Integer orgId) + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException; /** * Get URL used to request updated list of servers from registry @@ -82,7 +88,8 @@ * @return HashMap containing no. of new, updated, and deleted servers as a result of update. * @throws FederationException */ - public HashMap updateFederationRegistry() throws FederationException; + public HashMap updateFederationRegistry() + throws FederationException, MalformedURLException, SAXException, ParserConfigurationException, IOException; /** * Finds the fedServer whose URL matches the given host.