/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
// UARequester.java: Requester operations for UA.
// Author: James Kempf
// Created On: Thu Jan 8 15:17:35 1998
// Last Modified By: James Kempf
// Last Modified On: Mon Feb 22 13:47:06 1999
// Update Count: 78
//
/**
* The URequester class implements the Locator interface.
* It handles the request for the API. If any of the parameters
* are missing, they will be supplied with a default value if
* possible. If a cached value may be supplied, it will be.
* If no DA is present, and convergence is used to gather
* results, these will be merged into one result.
*
* @author Erik Guttman, James Kempf
*/
}
}
}
/**
* Return the Locator's locale object. All requests are made in
* this locale.
*
* @return The Locale object.
*/
return locale;
}
/**
* Return an enumeration of known service types for this scope and naming
* authority. Unless a proprietary or experimental service is being
* discovered, the namingAuthority parameter should be the empty
* string, "".
*
* @param NA The naming authority, "" for default,
* '*' for any naming authority.
* @param scopes The SLP scopes of the types.
* @return ServiceLocationEnumeration of ServiceType objects for
* the service type names.
* @exception IllegalArgumentException If any of the parameters are
* null or syntactically incorrect.
* @exception ServiceLocationException An exception is thrown if the
* operation fails.
*/
public synchronized ServiceLocationEnumeration
throws ServiceLocationException {
// Formulate and send off messages.
NA,
null,
null,
scopes);
// Collate results.
for (i = 0; i < n; i++) {
// Check for errors.
}
// Return.
return new ServiceLocationEnumerator(ret);
}
/**
* Return an enumeration of ServiceURL objects for services matching
* the query. The services are returned from the locale of the
* locator.
*
* @param type The type of the service (e.g. printer, etc.).
* @param scopes The SLP scopes of the service types.
* @param query A string with the SLP query.
* @return ServiceLocationEnumeration of ServiceURL objects for
* services matching the
* attributes.
* @exception ServiceLocationException An exception is returned if the
* operation fails.
* @see ServiceURL
*/
public synchronized ServiceLocationEnumeration
throws ServiceLocationException {
// Formulate and send off messages.
type,
type,
scopes);
// Collate results.
for (i = 0; i < n; i++) {
// Check for errors.
// Be sure to account for DAAdverts and SAAdverts.
serviceURLs = new Vector();
serviceURLs = new Vector();
}
}
// Return.
return new ServiceLocationEnumerator(ret);
}
/**
* Return the attributes for the service URL, using the locale
* of the locator.
*
* @param URL The service URL.
* @param scopes The SLP scopes of the service.
* @param attributeIds A vector of strings identifying the desired
* attributes. A null value means return all
* the attributes. <b>Partial id strings</b> may
* begin with '*' to match all ids which end with
* the given suffix, or end with '*' to match all
* ids which begin with a given prefix, or begin
* and end with '*' to do substring matching for
* ids containing the given partial id.
* @return ServiceLocationEnumeration of ServiceLocationAttribute
* objects matching the ids.
* @exception ServiceLocationException An exception is returned if the
* operation fails.
* @exception IllegalArgumentException If any of the parameters are
* null or syntactically incorrect.
* @see ServiceLocationAttribute
*
*/
public synchronized ServiceLocationEnumeration
throws ServiceLocationException {
URL,
scopes);
// Check results.
// We only take the first message that came back and is OK.
for (i = 0; i < n; i++) {
// Check for errors.
// Select out attribute list.
// Need to check that URL matches.
continue;
}
// Need to check that URL matches.
continue;
}
}
// Truncate, if return is larger than maximum.
}
// Break out, we only need one.
break;
}
// Return.
return new ServiceLocationEnumerator(ret);
}
/**
* Return all attributes for all service URL's having this
* service type in the locale of the Locator.
*
* @param type The service type.
* @param scopes The SLP scopes of the service type.
* @param attributeIds A vector of strings identifying the desired
* attributes. A null value means return all
* the attributes. <b>Partial id strings</b> may
* begin with '*' to match all ids which end with
* the given suffix, or end with '*' to match all
* ids which begin with a given prefix, or begin
* and end with '*' to do substring matching for
* ids containing the given partial id.
* @return ServiceLocationEnumeration of ServiceLocationAttribute
* objects matching the ids.
* @exception ServiceLocationException An exception is returned if the
* operation fails.
* @exception IllegalArgumentException If any of the parameters are
* null or syntactically incorrect.
* @see ServiceLocationAttribute
*
*/
public synchronized ServiceLocationEnumeration
throws ServiceLocationException {
// Formulate and send off messages.
type,
type,
scopes);
// Collate results.
// Check for errors.
// Get the instance variable.
}
// Merge any duplicates.
for (j = 0; j < m; j++) {
ht,
ret,
true);
break;
}
}
}
// Return.
return new ServiceLocationEnumerator(ret);
}
// Execute the message request, returning messages.
private Vector
throws ServiceLocationException {
// Validate, lower case scopes.
// Get the hashtable of unicast DA addresses and multicast scopes.
// Get multicast scopes and DA addresses.
// Special case for service request and attribute request
// if the user is looking for a special SLP type.
daAddresses = null;
// Get query. If an attribute request, then the user
// needs to sort out the attributes.
}
} else {
// Handle a regular message.
// Multicast scopes are all scopes not supported by any DA.
if (multiCastScopes != null) {
switch (msgType) {
case SrvLocHeader.SrvTypeRqst:
multiMsg =
break;
case SrvLocHeader.SrvReq:
multiMsg =
break;
case SrvLocHeader.AttrRqst:
if (t1 instanceof ServiceURL) {
multiMsg =
(ServiceURL)t1,
} else {
multiMsg =
type,
}
}
}
// Unicast only requires a single message because the DAs will
// ignore any scopes they do not support, just as long as
// they support one of them.
if (daAddresses != null) {
switch (msgType) {
case SrvLocHeader.SrvTypeRqst:
uniMsg =
break;
case SrvLocHeader.SrvReq:
uniMsg =
break;
case SrvLocHeader.AttrRqst:
if (t1 instanceof ServiceURL) {
uniMsg =
(ServiceURL)t1,
} else {
uniMsg =
type,
}
}
}
}
// Send off messages, return results.
}
// Check message for error code.
private static void
throws ServiceLocationException {
if (v.size() == 1) {
new Object[] {
throw
new ServiceLocationException((short)err,
"remote_error",
new Object[] {});
} else {
new Object[] {
}
}
}
// Process the incoming vector, adding any unique returns.
for (i = 0; i < n; i++) {
returns.addElement(o);
}
}
}
}