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// SLPV1SDAAdvert.java: SLPv1 DAAdvert, server side.
2N/A// Author: James Kempf
2N/A// Created On: Thu Sep 10 11:00:26 1998
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Mon Nov 2 15:55:47 1998
2N/A// Update Count: 27
2N/A//
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 SLPV1SDAAdvert class models the SLPv1 DAAdvert message.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/Aclass SLPV1SDAAdvert extends SDAAdvert {
2N/A
2N/A SLPV1SDAAdvert(SrvLocHeader hdr,
2N/A short xid,
2N/A long timestamp,
2N/A ServiceURL url,
2N/A Vector scopes,
2N/A Vector attrs)
2N/A throws ServiceLocationException {
2N/A
2N/A super(hdr, xid, timestamp, url, scopes, attrs);
2N/A
2N/A }
2N/A
2N/A // Initialize the message.
2N/A
2N/A void initialize(long timestamp,
2N/A ServiceURL url,
2N/A Vector scopes,
2N/A Vector attrs)
2N/A throws ServiceLocationException {
2N/A
2N/A // By using the incoming header, we are assured of
2N/A // getting the encoding required by the client.
2N/A
2N/A SLPHeaderV1 hdr = (SLPHeaderV1)this.hdr;
2N/A
2N/A int i, n = scopes.size();
2N/A
2N/A for (i = 0; i < n; i++) {
2N/A hdr.validateScope((String)scopes.elementAt(i));
2N/A
2N/A }
2N/A
2N/A // If the only scope we support is default and we are to
2N/A // support unscoped regs, then advertise us
2N/A // as an unscoped DA. However, if default is there with others,
2N/A // we keep it.
2N/A
2N/A SLPConfig config = SLPConfig.getSLPConfig();
2N/A
2N/A if (config.getAcceptSLPv1UnscopedRegs() &&
2N/A scopes.size() <= 1 &&
2N/A scopes.contains(Defaults.DEFAULT_SCOPE)) {
2N/A scopes.removeAllElements();
2N/A
2N/A }
2N/A
2N/A // Parse out the payload.
2N/A
2N/A ByteArrayOutputStream baos = new ByteArrayOutputStream();
2N/A
2N/A // Parse out the URL.
2N/A
2N/A hdr.parseServiceURLOut(url, false, baos);
2N/A
2N/A // Parse out the scope list. Same in V1 and V2.
2N/A
2N/A hdr.parseCommaSeparatedListOut(scopes, baos);
2N/A
2N/A hdr.payload = baos.toByteArray();
2N/A
2N/A hdr.iNumReplies = 1;
2N/A
2N/A hdr.constructDescription("DAAdvert",
2N/A " URL=``" + url + "''\n" +
2N/A " scopes=``" + scopes + "''\n");
2N/A
2N/A }
2N/A}