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// SLPV1SSrvDereg.java: Message class for SLP service deregistration
2N/A// request.
2N/A// Author: James Kempf
2N/A// Created On: Thu Oct 9 15:00:38 1997
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Mon Jan 4 15:26:33 1999
2N/A// Update Count: 82
2N/A//
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.io.*;
2N/A
2N/A
2N/A/**
2N/A * The SLPV1SSrvDereg class models the server side SLP service
2N/A * deregistration.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/A
2N/Aclass SLPV1SSrvDereg extends SSrvDereg {
2N/A
2N/A // Construct a SLPV1SSrvDereg from the byte input stream.
2N/A
2N/A SLPV1SSrvDereg(SrvLocHeader hdr, DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A super(hdr, dis);
2N/A
2N/A }
2N/A
2N/A // Initialize the object.
2N/A
2N/A void initialize(DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A SLPHeaderV1 hdr = (SLPHeaderV1)getHeader();
2N/A StringBuffer buf = new StringBuffer();
2N/A
2N/A // Parse in the service URL.
2N/A
2N/A URL =
2N/A hdr.parseServiceURLIn(dis,
2N/A false,
2N/A ServiceLocationException.INVALID_REGISTRATION);
2N/A
2N/A hdr.getString(buf, dis);
2N/A
2N/A tags = hdr.parseCommaSeparatedListIn(buf.toString().trim(), true);
2N/A
2N/A // Error if any tags are wildcarded. Only allowed for AttrRqst.
2N/A
2N/A int i, n = tags.size();
2N/A
2N/A for (i = 0; i < n; i++) {
2N/A String tag = (String)tags.elementAt(i);
2N/A
2N/A // Unescape tag.
2N/A
2N/A tag =
2N/A ServiceLocationAttributeV1.unescapeAttributeString(tag,
2N/A hdr.charCode);
2N/A
2N/A if (tag.startsWith("*") || tag.endsWith("*")) {
2N/A throw
2N/A new ServiceLocationException(
2N/A ServiceLocationException.PARSE_ERROR,
2N/A "v1_dereg_wildcard",
2N/A new Object[0]);
2N/A }
2N/A
2N/A tags.setElementAt(tag, i);
2N/A }
2N/A
2N/A // If no tags, then set the tags vector to null. This indicates
2N/A // that the service: URL needs to be deregistered.
2N/A
2N/A if (tags.size() <= 0) {
2N/A tags = null;
2N/A }
2N/A
2N/A // We need to find all the scopes for this guy and put them into the
2N/A // scope list on the header.
2N/A
2N/A ServiceTable table = ServiceTable.getServiceTable();
2N/A
2N/A ServiceStore.ServiceRecord rec = table.getServiceRecord(URL,
2N/A hdr.locale);
2N/A
2N/A // If the record is there, then get the scopes.
2N/A
2N/A if (rec != null) {
2N/A hdr.scopes = (Vector)rec.getScopes().clone();
2N/A
2N/A } else {
2N/A
2N/A SLPConfig config = SLPConfig.getSLPConfig();
2N/A
2N/A // We simply put in the useScopes, just to make the request.
2N/A // The request will be rejected when presented to ServiceTable.
2N/A
2N/A hdr.scopes = (Vector)config.getSAConfiguredScopes().clone();
2N/A
2N/A }
2N/A
2N/A hdr.constructDescription("SrvDereg",
2N/A " URL=``" + URL + "''\n" +
2N/A " tags=``" + tags + "''\n");
2N/A
2N/A }
2N/A
2N/A // Return a SrvAck.
2N/A
2N/A SrvLocMsg makeReply() {
2N/A
2N/A SLPHeaderV1 hdr = ((SLPHeaderV1)getHeader()).makeReplyHeader();
2N/A
2N/A // Construct description.
2N/A
2N/A hdr.constructDescription("SrvAck", "");
2N/A
2N/A return hdr;
2N/A
2N/A }
2N/A}