2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A *
2N/A */
2N/A
2N/A// ServiceLocationException.java : All SLP exceptions are derived from
2N/A// this base class.
2N/A// Author: Erik Guttman
2N/A//
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.text.*;
2N/A
2N/A/**
2N/A * The ServiceLocationException class is thrown when an error occurs
2N/A * during SLP operation. The exact nature of the error is indicated
2N/A * by the integer error codes.
2N/A *
2N/A * @author Erik Guttman
2N/A */
2N/A
2N/Apublic class ServiceLocationException extends Exception {
2N/A
2N/A // Error codes.
2N/A
2N/A /**
2N/A * No error.
2N/A */
2N/A
2N/A static final short OK = 0;
2N/A
2N/A /**
2N/A * The DA did not have a registration in the language locale of
2N/A * the request, although it did have one in another language locale.
2N/A */
2N/A
2N/A public static final short LANGUAGE_NOT_SUPPORTED = 1;
2N/A
2N/A /**
2N/A * An error occured while parsing a URL, attribute list, or a
2N/A * service location template document. This error is also returned
2N/A * from DA's when an otherwise unclassifiable internal error occurs.
2N/A */
2N/A
2N/A public static final short PARSE_ERROR = 2;
2N/A
2N/A /**
2N/A * Upon registration, this error is returned if the URL is invalid or
2N/A * if some other problem occurs with the registration. Upon deregistration
2N/A * it is also returned if the URL is not registered.
2N/A */
2N/A
2N/A
2N/A public static final short INVALID_REGISTRATION = 3;
2N/A
2N/A /**
2N/A * An attempt was made to register in a scope not supported by the DA.
2N/A * This error is also returned if an attempt is made to perform a
2N/A * registration or deregistration on a machine where a DA is running,
2N/A * since DA machines don't support SA functionality.
2N/A */
2N/A
2N/A public static final short SCOPE_NOT_SUPPORTED = 4;
2N/A
2N/A /**
2N/A * The DA or SA receives a request for an unsupported SLP SPI.
2N/A */
2N/A public static final short AUTHENTICATION_UNKNOWN = 5;
2N/A
2N/A /**
2N/A * A message for which an signature block was required is missing
2N/A * the block.
2N/A */
2N/A
2N/A public static final short AUTHENTICATION_ABSENT = 6;
2N/A
2N/A /**
2N/A * A signature block failed to authenticate.
2N/A */
2N/A
2N/A public static final short AUTHENTICATION_FAILED = 7;
2N/A
2N/A /**
2N/A * The version was not supported. This is surfaced to the client as a
2N/A * no results.
2N/A */
2N/A
2N/A static final short VERSION_NOT_SUPPORTED = 9;
2N/A
2N/A /**
2N/A * The DA encountered an internal error.
2N/A */
2N/A
2N/A static final short INTERNAL_ERROR = 10;
2N/A
2N/A /**
2N/A * The DA was busy. This is not surfaced to the client.
2N/A */
2N/A
2N/A
2N/A static final short DA_BUSY = 11;
2N/A
2N/A /**
2N/A * An option was received by the DA that wasn't supported. This is
2N/A * surfaced to the client as no results.
2N/A */
2N/A
2N/A static final short OPTION_NOT_SUPPORTED = 12;
2N/A
2N/A
2N/A /**
2N/A * An attempt was made to update a nonexisting registration.
2N/A */
2N/A
2N/A public static final short INVALID_UPDATE = 13;
2N/A
2N/A /**
2N/A * The remote agent doesn't support the request. Not surfaced to
2N/A * the client.
2N/A */
2N/A
2N/A static final short REQUEST_NOT_SUPPORTED = 14;
2N/A
2N/A /**
2N/A * For SA, the DA valid lifetime intervals for
2N/A * different DAs do not overlap.
2N/A */
2N/A
2N/A public static final short INVALID_LIFETIME = 15;
2N/A
2N/A // Internal error codes.
2N/A
2N/A /**
2N/A * Operation isn't implemented.
2N/A */
2N/A
2N/A public static final short NOT_IMPLEMENTED = 16;
2N/A
2N/A /**
2N/A * Initialization of the network failed.
2N/A */
2N/A
2N/A public static final short NETWORK_INIT_FAILED = 17;
2N/A
2N/A /**
2N/A * A TCP connection timed out.
2N/A */
2N/A
2N/A public static final short NETWORK_TIMED_OUT = 18;
2N/A
2N/A /**
2N/A * An error occured during networking.
2N/A */
2N/A
2N/A public static final short NETWORK_ERROR = 19;
2N/A
2N/A /**
2N/A * An error occured in the client-side code.
2N/A */
2N/A
2N/A public static final short INTERNAL_SYSTEM_ERROR = 20;
2N/A
2N/A /*
2N/A * Registration failed to match the service type template.
2N/A */
2N/A
2N/A public static final short TYPE_ERROR = 21;
2N/A
2N/A /**
2N/A * Packet size overflow.
2N/A */
2N/A
2N/A public static final short BUFFER_OVERFLOW = 22;
2N/A
2N/A /**
2N/A * Overflow due to previous responder list being too long.
2N/A */
2N/A
2N/A static final short PREVIOUS_RESPONDER_OVERFLOW = 100;
2N/A
2N/A // The error code for this exception.
2N/A
2N/A private short errorCode = OK;
2N/A
2N/A // The message arguments.
2N/A
2N/A private Object[] params = null;
2N/A
2N/A // allows additional information to be added to the message
2N/A
2N/A private String addendum = "";
2N/A
2N/A ServiceLocationException(short errorCode, String msgTag, Object[] params) {
2N/A super(msgTag);
2N/A
2N/A this.params = params;
2N/A this.errorCode = errorCode;
2N/A }
2N/A
2N/A // Return true if this is a vaild on-the-wire error code.
2N/A
2N/A static boolean validWireErrorCode(int code) {
2N/A return ((code >= OK) && (code <= REQUEST_NOT_SUPPORTED));
2N/A
2N/A }
2N/A
2N/A /**
2N/A * Return the error code.
2N/A *
2N/A * @return The integer error code.
2N/A */
2N/A
2N/A public short getErrorCode() {
2N/A return errorCode;
2N/A
2N/A }
2N/A
2N/A /**
2N/A * Return the localized message, in the default locale.
2N/A *
2N/A * @return The localized message.
2N/A */
2N/A
2N/A public String getMessage() {
2N/A return getLocalizedMessage(SLPConfig.getSLPConfig().getLocale()) +
2N/A addendum;
2N/A
2N/A }
2N/A
2N/A public String getLocalizedMessage(Locale locale) {
2N/A SLPConfig conf = SLPConfig.getSLPConfig();
2N/A return conf.formatMessage(super.getMessage(), params);
2N/A
2N/A }
2N/A
2N/A void makeAddendum(String addendum) {
2N/A this.addendum = addendum;
2N/A }
2N/A
2N/A}