private static SpaceURL parseURL(String url, Properties customProperties) throws MalformedURLException { if (url == null) throw new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method."); return SpaceURLParser.parseURL(url, customProperties); }
private static String initialValidate(String url) throws SpaceURLValidationException { //remove invalid spaces and Inverted Commas as part of SpaceURL url = JSpaceUtilities.removeInvertedCommas(url); url = JSpaceUtilities.removeDelimiter(url, ' ', '{', '}'); if (_logger.isLoggable(Level.FINE)) _logger.fine("Using SpaceURL: " + url); int first = url.indexOf('?'); if (first != url.lastIndexOf('?')) throw new SpaceURLValidationException("Invalid space url - The space url has more than one '?' character"); if (first == -1 && url.indexOf('&') > -1) throw new SpaceURLValidationException("Invalid space url - The space url contains the '&' delimiter but is missing the '?' character. Make sure the '?' character is set after the space/container name."); return url; }
public static Object find(SpaceURL spaceURL, CredentialsProvider credentialsProvider, long timeout, LookupType lookupType) throws FinderException { if (spaceURL == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); return spaceFinder.findService(spaceURL, spaceURL.getCustomProperties(), null /*lifeCycle*/, credentialsProvider, timeout, lookupType); }
/** * The method validates the space URL parameter names * * @param spaceURL the space URL */ private static void validateURL(SpaceURL spaceURL) throws SpaceURLValidationException { Enumeration names = spaceURL.propertyNames(); while (names.hasMoreElements()) { String property = names.nextElement().toString(); if (_logger.isLoggable(Level.FINE)) _logger.fine("Validating Space URL property: " + property + " = " + spaceURL.getProperty(property)); if (!urlElements.contains(property.toLowerCase())) throw new SpaceURLValidationException("Invalid space url property - '" + property + "'"); } } }
protected Object findService(String url, Properties customProperties, LifeCycle lifeCycle, CredentialsProvider credentialsProvider) throws FinderException { if (url == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); StringTokenizer st = new StringTokenizer(url, ";"); String[] urls = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) urls[i] = st.nextToken(); SpaceURL[] spaceURLs = prepareUrl(urls, customProperties); Properties customProps = spaceURLs[spaceURLs.length - 1].getCustomProperties(); return findService(spaceURLs, customProps, lifeCycle, credentialsProvider); }
private static SpaceURL[] prepareUrl(String[] urls, Properties customProperties) throws FinderException { //011205 Gershon - moved only to embedded space scenario and that is after loading //potential sys props from the custom properties. //JSpaceUtilities.setXMLImplSystemProps(); if (urls == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); if (urls.length == 0) throw new FinderException(new SpaceURLValidationException("Invalid space url - Invalid array size of SpaceURLs " + urls.length)); SpaceURL[] spaceUrls = new SpaceURL[urls.length]; for (int i = 0; i < urls.length; i++) { try { spaceUrls[i] = parseURL(urls[i], customProperties); } catch (Exception ex) { if (i == urls.length - 1) throw new FinderException(ex.getMessage(), ex); } } return spaceUrls; }
/** * <pre> * The general format for this URL is as follows: * Protocol://[host]:[port]/[container_name]/[space_name]?[query_string] * Protocol: [ RMI | JINI | JAVA ] * This method also supports multiple URLs separate by ";", * e.i. jini://localhost/containerName/SpaceName;jini://'*'/containerName/SpaceName; * It is useful when Jini URL for locating services on the network is not available. * If the first space URL is unavailable, SpaceFinder will try the next one until a live proxy * will be found. * If all URLs are unavailable this method throws FinderException * </pre> * * @param credentialsProvider credentials to be used for authentication against a remote secured * space; may be <code>null</code>. * @return Returns single Space or Container proxy. * @throws FinderException During finding space or container. */ public static Object find(SpaceURL spaceURL, CredentialsProvider credentialsProvider) throws FinderException { if (spaceURL == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); long timeout = Long.parseLong(spaceURL.getProperty(SpaceURL.TIMEOUT, "-1")); return spaceFinder.findService(spaceURL, spaceURL.getCustomProperties(), null /*lifeCycle*/, credentialsProvider, timeout, null /* lookupType */); }
protected Object findService(SpaceURL[] spaceURLs, Properties customProperties, LifeCycle lifeCycle, CredentialsProvider credentialsProvider) throws FinderException { if (spaceURLs == null || spaceURLs.length == 0) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); Properties actualCustomProperties; for (int i = 0; i < spaceURLs.length; i++) { try { actualCustomProperties = customProperties != null ? customProperties : spaceURLs[i].getCustomProperties(); long timeout = Long.parseLong(spaceURLs[i].getProperty(SpaceURL.TIMEOUT, "-1")); return findService(spaceURLs[i], actualCustomProperties, lifeCycle, credentialsProvider, timeout, null /* lookupType */); } catch (FinderException ex) { if (i == spaceURLs.length - 1) throw ex; } } // Should not happen - Satisfy the compiler throw new FinderException("find finished without returning result."); }
if (clusterTotalMembers.length == 1 && Integer.parseInt(clusterTotalMembers[0]) <= 1) { throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_TOTAL_MEMBERS + "> attribute must be larger than 1" + " in the space URL: " + spaceURL); throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_SCHEMA + "> attribute must be used together with the <" + SpaceURL.CLUSTER_TOTAL_MEMBERS + "> attribute " + throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_TOTAL_MEMBERS + "> attribute must be used together with the <" + SpaceURL.CLUSTER_SCHEMA + "> attribute " + spaceURL.containsKey(SpaceURL.CLUSTER_TOTAL_MEMBERS)) { if (!spaceURL.containsKey(SpaceURL.CLUSTER_MEMBER_ID)) { throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_SCHEMA + "=" + spaceURL.getProperty(SpaceURL.CLUSTER_SCHEMA) + "> attribute must be used together with the <" + SpaceURL.CLUSTER_MEMBER_ID + "> attribute in the space URL: " + spaceURL); int bNum = Integer.valueOf(totalMembersArray[1]).intValue(); if (pNum < 1 || bNum < 0) { throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_SCHEMA + "=" + clusterSchema + "> attribute must be used together with total_members attribute in the following format " + "total_members={number of primary instances, number of backup instances per primary} " + throw new SpaceURLValidationException("The <" + SpaceURL.CLUSTER_SCHEMA + "="
throw new SpaceURLValidationException("Invalid space url - " + spaceURLStr); throw new SpaceURLValidationException("Invalid space url - Unknown protocol found in space url: " + spaceURLStr); // check if URL not equal to protocol://host/* otherwise MalformedURLException will be throw throw new SpaceURLValidationException("Invalid space url - " + spaceURLStr throw new SpaceURLValidationException("Invalid space url - " + spaceURLStr throw new SpaceURLValidationException("Invalid space url - " + spaceURLStr throw new SpaceURLValidationException("Invalid space url - " + spaceURLStr
throw new SpaceURLValidationException("Unsupported url protocol: " + url.getProtocol());