a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington/*
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * The contents of this file are subject to the terms of the Common Development and
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Distribution License (the License). You may not use this file except in compliance with the
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * License.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott *
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * specific language governing permission and limitations under the License.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott *
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * When distributing Covered Software, include this CDDL Header Notice in each file and include
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Header, with the fields enclosed by brackets [] replaced by your own identifying
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * information: "Portions copyright [year] [name of copyright owner]".
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington *
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington * Copyright 2014-2015 ForgeRock AS.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottpackage com.iplanet.services.naming;
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottimport java.net.URL;
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlalimport java.util.Collection;
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottimport java.util.Set;
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott/**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * Provides a non-static wrapper around WebtopNaming so this service
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * can be injected into classes using Guice and tested appropriately.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottpublic class WebtopNamingQuery {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#getSiteID(String)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param server Non null Server ID.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return Null if the server was not part of a Site, or not found in any Site.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public String getSiteID(String server) {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.getSiteID(server);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#getServerFromID(String)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param server The ID of the Server as described in the naming table.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return A URL based on the Servers entry in the naming table.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @throws ServerEntryNotFoundException If the server was not found in the naming table.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public String getServerFromID(String server) throws ServerEntryNotFoundException {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.getServerFromID(server);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#getAMServerID()
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return The ID of the current Server.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @throws ServerEntryNotFoundException If there was a problem resolving this ID.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public String getAMServerID() throws ServerEntryNotFoundException {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.getAMServerID();
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#isSite(String)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param siteID The ID of the Site or Server to test.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return True if the ID belongs to a Site ID. False if not valid or is a Server ID.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public boolean isSite(String siteID) {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.isSite(siteID);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#isServer(String)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param serverID The ID of the Site or Server to test.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return True if the ID belongs to a Server. False if not valid or is a Site ID.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public boolean isServer(String serverID) {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.isServer(serverID);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see WebtopNaming#getSiteNodes(String)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param siteID Non null Site ID.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return The ServerIDs that make up the Site.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @throws Exception If there was a problem determining the Site nodes.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public Set<String> getSiteNodes(String siteID) throws Exception {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.getSiteNodes(siteID);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott /**
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @see com.iplanet.services.naming.WebtopNaming.SiteMonitor#isAvailable(java.net.URL)
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @param url Non null URL to test. This URL must point to an OpenAM Server
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * instance.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott * @return True indicates that the Server is up and responding.
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott */
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott public boolean isAvailable(URL url) throws Exception {
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott return WebtopNaming.SiteMonitor.isAvailable(url);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott }
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal /**
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @see WebtopNaming#getAllServerIDs()
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @return all server IDs.
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal * @throws Exception if an error occurs when getting all the server ids
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal */
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal public Collection<String> getAllServerIDs() throws Exception {
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal return WebtopNaming.getAllServerIDs();
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal }
8808bf6434d4dd628636c2ed08b8b0fe6baa5752Dipu Seminlal
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott public SessionIDCorrector getSessionIDCorrector() {
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott return WebtopNaming.getSessionIDCorrector();
1d407e39b7d8f68d9a2b1e178f35fab037d9835aRobert Wapshott };
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott}